<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../static/css/drag.css">
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="../static/js/drag.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        html,body{
            height: 100%;
        }
        .clear:after{
            content: "";
            clear: both;
            display: block;
        }
        .header{
            height: 60px;
            background-color: greenyellow;
        }
        .par{
            height:calc(100% - 60px);
        }
        .left{
            width: 200px;
            height: 200px;
            background-color: #e714ff;
            float: left;
            box-sizing: border-box;
            height: 100%;
        }
        .left ul{
             background-color: aqua;
            text-align: center;
        }
        .left ul li{
            list-style: none;
            height: 26px;
            line-height: 26px;
        }
        .left ul .switch{
            background-color: gray;
        }
        .right{
            height: 200px;
            background-color: #7a4dff;
            float: left;
            box-sizing: border-box;
            width: calc(100% - 200px);
            height: 100%;

        }
    </style>
</head>
<body>
<div class="header"></div>
<div class="par clear">
    <div class="left">
        <ul>
            <li class="switch" isClose="true">button</li>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
        </ul>
    </div>
    <div class="right"></div>
</div>
</body>
<script>
    $(function () {
        $(".left").dragLayout({
            maxWidth:600,
            minWidth:10
        });
        
        $(".switch").on("click",function () {
            if($(this).attr("isClose")=="true"){
                $(".dragTarget").remove();
                $('.left').animate({ width:"20px"}, 500, function() {
                    $(".left").dragLayout({
                        maxWidth:600,
                        minWidth:10
                    });
                });
                $('.right').animate({width: $(".right").outerWidth()+  $('.left').outerWidth()-20+"px"}, 500, function() {});
                $(this).attr("isClose","false")
            }else{
                $(".dragTarget").remove();
                $('.left').animate({width:"200px"}, 500, function() {
                    $(".left").dragLayout({
                        maxWidth:600,
                        minWidth:10
                    });
                });
                $('.right').animate({width: $(".right").outerWidth()- (200-$('.left').outerWidth())+"px"}, 500, function() {});
                $(this).attr("isClose","true")
            }

        })
    })
</script>
</html>